package controllers;

import play.*;
import play.mvc.*;

import java.util.*;

import models.*;

public class Register extends Controller {

	static public void emailExistsJSON() {
		String email = params.get("e");
		if(User.emailExists(email)) {
			renderJSON(true);
		} else {
			renderJSON(false);
		}
	} 
	
	// need to make sure register can be done. -- i.e. no email duplicate
	static public void registerUserJSON() {
		String email = params.get("e");
		String password = params.get("p");
		User u = new User(email, password).save();
		renderJSON(u, new UserSerializer());
	}
    
}

